import  java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int len = in.nextInt();
            String text = in.next();
            if (len == 0) {
                System.out.print(0);
                return;
            }
            int[] arr = new int[len];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = i + 1;
            }

            char[] tmp = text.toCharArray();
            int j = 1;
            for (int i = 0; i < tmp.length; i++) {
                if (tmp[i] == 'U') {
                    if (j == 1) {
                        j = 10;
                    } else {
                        j--;
                    }
                }
                if (tmp[i] == 'D') {
                    if (j == 10) {
                        j = 1;
                    } else {
                        j++;
                    }
                }
            }
            int k = j;
            for (int i = 0; i < 4; i++) {
                int ret = (j + arr.length-1) % arr.length;
                System.out.print(arr[ret]);
                j++;
            }
            System.out.println();
            System.out.println(k);

        }
    }
    public static void main3(String[] args) {
        char[] arr=new char[]{'a','b'};
        arr.toString();
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        //while (in.hasNextInt()) { // 注意 while 处理多个 case
           String text=in.nextLine();
           int left=0;
           int right=text.length()-1;
           char[] arr=text.toCharArray();
           while(left<right){
            swap(arr,left,right);
            left++;
            right--;
           }
            System.out.printf(Arrays.toString(arr));
      // }
        }
    public static void swap(char[] arr,int left,int right){
        char tmp=arr[left];
       arr[left]=arr[right];
       arr[right]=tmp;
    }
}